package entities;

public class Event {
    private Long id;
    private String title;
    private String description;
    private Double lat;
    private Double lng;
    private Integer year;
    private Integer day;
    private EventType type;

    public Event(Long id, String title, Double lat, Double lng, Integer year, Integer day, EventType type) {
        this.id = id;
        this.title = title;
        this.lat = lat;
        this.lng = lng;
        this.year = year;
        this.day = day;
        this.type = type;
    }

    public Event(Double lat, Double lng, Integer year, Integer day) {
        this.lat = lat;
        this.lng = lng;
        this.year = year;
        this.day = day;
    }

    public Event() {
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the title
     */
    public String getTitle() {
        return title;
    }

    /**
     * @param title the title to set
     */
    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the lat
     */
    public Double getLat() {
        return lat;
    }

    /**
     * @param lat the lat to set
     */
    public void setLat(Double lat) {
        this.lat = lat;
    }

    /**
     * @return the lng
     */
    public Double getLng() {
        return lng;
    }

    /**
     * @param lng the lng to set
     */
    public void setLng(Double lng) {
        this.lng = lng;
    }

    public Integer getDay() {
        return day;
    }

    public void setDay(Integer day) {
        this.day = day;
    }

    public Integer getYear() {
        return year;
    }

    public void setYear(Integer year) {
        this.year = year;
    }

    public EventType getType() {
        return type;
    }

    public void setType(EventType type) {
        this.type = type;
    }

    @Override
    public String toString() {
        return title;
    }

    public String toJSON() {
        StringBuilder sb = new StringBuilder("{");
        sb.append("id:"+id);
        if (title != null)
            sb.append(",title:'"+title+"'");
        if (description != null)
            sb.append(",description:'"+description+"'");
        if (lat != null)
            sb.append(",lat:'"+lat+"'");
        if (lng != null)
            sb.append(",lng:'"+lng+"'");
        if (year != null)
            sb.append(",year:'"+year+"'");
        if (day != null)
            sb.append(",day:'"+day+"'");
        if (type != null) {
            if (type.getName() != null)
                sb.append(",type:'"+type.getName()+"'");
            if (type.getIconUrl() != null)
                sb.append(",iconUrl:'"+type.getIconUrl()+"'");
        }
        sb.append("}");
        return sb.toString();
    }
}
